﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Billing.Dtos;
using Billing.Utilities;
using System.Collections;
using System.Data;

namespace Billing.Windows
{
    /// <summary>
    /// Interaction logic for VendorBills.xaml
    /// </summary>
    public partial class VendorBills : Window
    {
        VendorBillingGrid grid = null;

        public VendorBills()
        {
            InitializeComponent();
            cmbVendor.DataContext = Database.GetVendorCompanies();
            cmbVendor.Focus();
            cmbVendor.SelectedIndex = 0;
        }

        private void Window_KeyUp(object sender, KeyEventArgs e)
        {
            try
            {
                if (e.Key == Key.Escape)
                {
                    this.Close();
                }
                else if (e.Key == Key.F1)
                {
                    if (grid == null)
                    {
                        grid = new VendorBillingGrid(((cmbVendor as ListBox).SelectedItem as DataRowView).Row[1].ToString(), Convert.ToInt32(((cmbVendor as ListBox).SelectedItem as DataRowView).Row[0].ToString()));
                        grid.Owner = this;
                        grid.ShowDialog();
                        this.Close();
                    }
                    else
                        this.Close();
                }
            }
            catch (Exception) { }
        }
    }
}
